<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
        <title>添加授课班学生</title>
        <include file='Layout:ins_css' />
        <style type="text/css">
            #addBtn {
                float: right;
                margin: -7px -6px 9px;
            }
        </style>
    </head>
    <body>
        <div class="wrapper wrapper-content animated fadeInRight">
            <div class="row">
                <div class="col-sm-12">
                    <div class="ibox float-e-margins">
                        <div class="ibox-title">
                            <h5>添加授课班学生</h5>
                            <!--<button class="btn btn-primary" id="addBtn">新增</button>-->
                        </div>
                        <div class="row s-row">
                            <div class="col-sm-12">
                                <div class="price-div">
                                    <form class="form-horizontal">
                                        <div class="form-group cyf-form-group">
                                            <div class="col-sm-4" style="margin-top: 10px; margin-bottom: 10px">
                                                <label style="float: left" class="col-sm-4 control-label cvbnm">学院: </label>
                                                <select class="form-control col-sm-" id="college_id" name="college_id" style="min-height: 35px">
                                                    <option value="0">全部</option>
                                                    <volist name="college_info" id="college_info">
                                                        <option value="{$college_info.sch_id}">{$college_info.sch_name}</option>
                                                    </volist>
                                                </select>
                                            </div>
                                            <div class="col-sm-4" style="margin-top: 10px; margin-bottom: 10px">
                                                <label style="float: left; margin-right: 13px" class="col-sm-4 control-label cvbnm">系: </label>
                                                <select class="form-control col-sm-" id="department_id" name="department_id" style="min-height: 35px">
                                                    <option value="0">全部</option>
                                                    <volist name="department_info" id="department_info">
                                                        <option value="{$department_info.dept_id}" pid="{$department_info.sch_id}"  style="display: none;">{$department_info.dept_name}</option>
                                                    </volist>
                                                </select>
                                            </div>
                                            <div class="col-sm-4" style="margin-top: 10px; margin-bottom: 10px">
                                                <label style="float: left;" class="col-sm-4 control-label cvbnm">专业: </label>
                                                <select class="form-control col-sm-" id="noun_id" name="noun_id" style="min-height: 35px">
                                                    <option value="0">全部</option>
                                                    <volist name="noun_info" id="noun_info">
                                                        <option value="{$noun_info.pro_id}" pid="{$noun_info.dept_id}"  style="display: none;">{$noun_info.pro_name}</option>
                                                    </volist>
                                                </select>
                                            </div>
                                        </div>
                                        <div class="form-group cyf-form-group">
                                            <div class="col-sm-4" style="margin-top: 10px; margin-bottom: 10px">
                                                <label style="float: left;" class="col-sm-4 control-label cvbnm">专业: </label>
                                                <select class="form-control col-sm-" id="class_id" name="class_id" style="min-height: 35px">
                                                    <option value="0">全部</option>
                                                    <volist name="class_info" id="class_info">
                                                        <option value="{$class_info.cla_id}" pid="{$class_info.pro_id}"  style="display: none;">{$class_info.cla_name}</option>
                                                    </volist>
                                                </select>
                                            </div>
                                        </div>
                                        <div class="form-group cyf-form-group">
                                            <div class="col-sm-4" style="margin-top: 10px; margin-bottom: 10px">
                                                <label style="float: left;" class="col-sm-4 control-label cvbnm">学号: </label>
                                                <input type="text" id="find_stu_number" name="find_stu_number" class="form-control" style="min-height: 30px"/>
                                            </div>
                                        </div>
                                        <div class="form-group cyf-form-group">
                                            <div class="col-sm-7" style="margin-top: 10px; margin-bottom: 10px">
                                                <label style="float: left;text-align: center" class="col-sm-2 col-sm-offset-1 btn btn-info  cvbnm">添加到授课班: </label>
                                                <div class="col-sm-7">
                                                    <input readonly="readonly" type="text" id="" name="" value="{$tec_name}" class="form-control removeData">
                                                </div>
                                            </div>
                                        </div>
                                    </form>
                                </div>
                            </div>
                        </div>
                        <div class="ibox-content">
                            <table class="table table-striped table-bordered table-hover dataTables-example" id="RuleTable">
                                <thead>
                                    <tr>
                                        <th width="4%"> <input type="checkbox" id="checkall"></th>
                                        <th width="16%">学号</th>
                                        <th width="16%">姓名</th>
                                        <th width="16%">性别</th>
                                        <th width="16%">专业</th>
                                        <th width="16%">状态</th>
                                        <th width="16%">操作</th>
                                    </tr>
                                </thead>
                                <tbody>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <include file='Layout:ins_js' />
        <script type="text/javascript">
            $(document).ready(function () {
                check_index();
                sTable = $(".table").DataTable({
                    "fnServerParams": function(aoData) {
                        aoData.push({
                            'name': 'class_id',
                            'value': $('select#class_id option:selected').val()
                        },{
                            'name': 'stu_num',
                            'value': $('#find_stu_number').val()
                        });
                    },
                    "bAutoWidth":false,
                    "oLanguage": {
                        "sLengthMenu": "每页 _MENU_ ",
                        "sProcessing": "处理中...",
                        "sZeroRecords": "没有匹配结果",
                        "sInfo": "显示第 _START_ 至 _END_ 项结果，共 _TOTAL_ 项",
                        "sInfoEmpty": "显示第 0 至 0 项结果，共 0 项",
                        "sInfoFiltered": "(由 _MAX_ 项结果过滤)",
                        "sInfoPostFix": "",
                        "sSearch": "搜索:",
                        "sUrl": "",
                        "sEmptyTable": "表中数据为空",
                        "sLoadingRecords": "载入中...",
                        "sInfoThousands": ",",
                        "oPaginate": {
                            "sFirst": "首页",
                            "sPrevious": "上页",
                            "sNext": "下页",
                            "sLast": "末页"
                        },
                        "oAria": {
                            "sSortAscending": ": 以升序排列此列",
                            "sSortDescending": ": 以降序排列此列"
                        }
                    },
                    "sAjaxSource": "__URL__/add_class_student_ShowDatatables", //调用php后台接口方法地址
                    "aoColumns": [{
                        "data": null,
                        orderable: false,
                        render: function(data, type, row, meta){
                            // var dat = {"stu_id":data.stu_id,"tc_id":data.tc_id};
                            var dat = data.stu_id + ',' + data.tc_id;
                            return '<input type="checkbox" name="checkBox" class="checkchild" value=" ' + dat +  '" > ';
                        }
                    },{
                        'data': 'stu_id'
                    },{
                        'data': 'stu_name'
                    },{
                        'data': 'cla_name'
                    },{
                        'data': 'stu_sex',
                    },{
                        'data': 'stu_status',
                    },{
                        "data": null,
                        orderable: false,
                        render: function(data, type, row, meta) {
                            return '<a type="button" class="btn btn-success" href="#" onclick=editFromID(this) >编辑</a>|<a type="button" class="btn btn-danger" href="#" onclick=delFromID(this) >删除</a>'
                        }
                    }]
                });
            });
            //查询按钮
            $("select#college_id").change(function() {
                //console.log( $('select#college_id option:selected').val());
                var p_id = $("#college_id").val();
                $("#department_id option").hide();
                $('#department_id').val('0');
                $('option[pid=' + p_id + ']').show();
            });
            $("select#department_id").change(function() {
                //console.log( $('select#college_id option:selected').val());
                var p_id = $("#department_id").val();
                $("#noun_id option").hide();
                $('#noun_id').val('0');
                $('#noun_id option[pid=' + p_id + ']').show();
            });
            $("select#noun_id").change(function(){
                var p_id = $("#noun_id").val();
                $("#class_id option").hide();
                $('#class_id').val('0');
                $('#class_id option[pid=' + p_id + ']').show();
            });
            $("#class_id").change(function () {
                sTable.ajax.reload();
            });

            $('#checkall').on('click',function(){
                var check = $(this).prop("checked");
                // $('.checkchild').prop('checked',check);
                sTable.$('.checkchild').prop('checked',check);
            });
            $("select#teaching_class_id").change(function(){
                //console.log($('select#class_id option:selected').val())
                sTable.ajax.reload();
            });
        </script>
    </body>
</html>